use "dta\LocalNationalWomenOverTime.dta", clear

** Type=1 local councilors
** Type=2 local mayors
** Type=3 Members of parliament 
** Type=4 Cabinet members
** Type=5 List leaders
** Type=6 National candidates

sort year type

* Generate individual graphs for each type
twoway (scatter fraction_women year if type==1, ///
    connect(l) lpattern(solid) lcolor(black) msymbol(circle) mcolor(black)), ///
    xlabel(1920 (15) 2025, labsize(small) angle(45)) ///
    ylabel(0(0.1)0.5, angle(0)) plotregion(lcolor(white) ilcolor(white)) graphregion(color(white)) ylabel(, gmax) ///
    xtitle(Election year) ytitle(Fraction women) ///
    title("Local Councilors") ///
    scheme(s2mono) ///
    legend(off) 
graph save "figures/gph/graph1.gph", replace

twoway (scatter fraction_women year if type==2, ///
    connect(l) lpattern(solid) lcolor(black) msymbol(circle) mcolor(black)), ///
    xlabel(1920 (15) 2025, labsize(small) angle(45)) ///
    ylabel(0(0.1)0.5, angle(0)) plotregion(lcolor(white) ilcolor(white)) graphregion(color(white)) ylabel(, gmax) ///
    xtitle(Election year) ytitle(Fraction women) ///
    title("Local Mayors") ///
    scheme(s2mono) ///
    legend(off)
graph save "figures/gph/graph2.gph", replace

twoway (scatter fraction_women year if type==3, ///
    connect(l) lpattern(solid) lcolor(black) msymbol(circle) mcolor(black)), ///
    xlabel(1920 (15) 2025, labsize(small) angle(45)) ///
    ylabel(0(0.1)0.5, angle(0)) plotregion(lcolor(white) ilcolor(white)) graphregion(color(white)) ylabel(, gmax) ///
    xtitle(Election year) ytitle(Fraction women) ///
    title("Members of Parliament") ///
    scheme(s2mono) ///
    legend(off)
graph save "figures/gph/graph3.gph", replace

twoway (scatter fraction_women year if type==4, ///
    connect(l) lpattern(solid) lcolor(black) msymbol(circle) mcolor(black)), ///
    xlabel(1920 (15) 2025, labsize(small) angle(45)) ///
    ylabel(0(0.1)0.5, angle(0)) plotregion(lcolor(white) ilcolor(white)) graphregion(color(white)) ylabel(, gmax) ///
    xtitle(Election year) ytitle(Fraction women) ///
    title("Cabinet Ministers") ///
    scheme(s2mono) ///
    legend(off)
graph save "figures/gph/graph4.gph", replace

twoway (scatter fraction_women year if type==5, ///
    connect(l) lpattern(solid) lcolor(black) msymbol(circle) mcolor(black)), ///
    xlabel(1920 (15) 2025, labsize(small) angle(45)) ///
    ylabel(0(0.1)0.5, angle(0)) plotregion(lcolor(white) ilcolor(white)) graphregion(color(white)) ylabel(, gmax) ///
    xtitle(Election year) ytitle(Fraction women) ///
    title("National List Leaders") ///
    scheme(s2mono) ///
    legend(off)
graph save "figures/gph/graph5.gph", replace

twoway (scatter fraction_women year if type==6, ///
    connect(l) lpattern(solid) lcolor(black) msymbol(circle) mcolor(black)), ///
    xlabel(1920 (15) 2025, labsize(small) angle(45)) ///
    ylabel(0(0.1)0.5, angle(0)) plotregion(lcolor(white) ilcolor(white)) graphregion(color(white)) ylabel(, gmax) ///
    xtitle(Election year) ytitle(Fraction women) ///
    title("National Candidates") ///
    scheme(s2mono) ///
    legend(off)
graph save "figures/gph/graph6.gph", replace

* Combine the graphs into one figure
cd figures/gph/
graph combine graph1.gph graph2.gph graph6.gph graph5.gph graph3.gph graph4.gph , ///
    rows(3) cols(3) ///
    title("") ///
    graphregion(color(white))
graph export ..\Figure1.pdf, replace
cd ../../
